// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   UserService.java

package com.nervytech.tutorcruise.db.service.impl;

import com.nervytech.tutorcruise.db.dao.interfaces.IUserDAO;
import com.nervytech.tutorcruise.db.dao.model.User;
import com.nervytech.tutorcruise.db.service.interfaces.IUserService;
import com.nervytech.tutorcruise.service.exception.TrainerCruiseServiceException;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("userService")
public class UserService implements IUserService {

	@Autowired
	private IUserDAO usrDao;

	public void saveUser(User user) throws TrainerCruiseServiceException {
		try {
			usrDao.saveUser(user);
		} catch (Exception e) {
			throw new TrainerCruiseServiceException(e.getMessage());
		}
	}

	public User getUser(long userId) {
		return null;
	}

	public void updateUser(User user1) {
	}

	public boolean checkIfUserExist(String emailId)
			throws TrainerCruiseServiceException {
		boolean isUserExist = false;
		try {
			isUserExist = usrDao.checkIfUserExist(emailId.trim().toLowerCase());
		} catch (Exception e) {
			throw new TrainerCruiseServiceException(e.getMessage());
		}
		return isUserExist;
	}

	public void updatePassword(long userId, String password)
			throws TrainerCruiseServiceException {
		try {
			usrDao.updatePassword(userId, password);
		} catch (Exception e) {
			throw new TrainerCruiseServiceException(e.getMessage());
		}
	}

	public void updateStatus(long userId, int userStatus)
			throws TrainerCruiseServiceException {
		try {
			usrDao.updateUserStatus(userId, userStatus);
		} catch (Exception e) {
			throw new TrainerCruiseServiceException(e.getMessage());
		}
	}

	public User getUserByEmail(String emailId)
			throws TrainerCruiseServiceException {
		User usr = null;
		List usrsList = null;
		try {
			usrsList = usrDao.getUserByEmailId(emailId.trim().toLowerCase());
			if (usrsList.size() > 0)
				usr = (User) usrsList.get(0);
		} catch (Exception e) {
			throw new TrainerCruiseServiceException(e.getMessage());
		}
		return usr;
	}

	public void updateLastLoginTime(int i, Date date) {
	}

	public void updateLastLoginTime(long l, Date date) {
	}

	public void updateUserTypeAndCategory(long userId, int userType,
			int category) throws TrainerCruiseServiceException {
		try {
			usrDao.updateUserTypeAndCategory(userId, userType, category);
		} catch (Exception e) {
			throw new TrainerCruiseServiceException(e.getMessage());
		}
	}

	public void updateFirstLogin(long userId, int userType, int category,
			String mobile, int mobileVerfied)
			throws TrainerCruiseServiceException {
		try {
			usrDao.updateFirstLogin(userId, userType, category, mobile,
					mobileVerfied);
		} catch (Exception e) {
			throw new TrainerCruiseServiceException(e.getMessage());
		}
	}

	public User getTraineeProfile(long userId)
			throws TrainerCruiseServiceException {
		User traineeProfile = null;
		List traineesList = null;
		try {
			traineesList = usrDao.getTraineeProfile(userId);
			if (traineesList.size() > 0)
				traineeProfile = (User) traineesList.get(0);
		} catch (Exception e) {
			e.printStackTrace();
			throw new TrainerCruiseServiceException(e.getMessage());
		}
		return traineeProfile;
	}

}
